package tree;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Optional;
import java.util.Scanner;
import java.util.stream.Collectors;

public class LeetCode_222 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double[][] goals = new double[n][2];
        for (int i = 0; i < n; i++) {
            double a = scanner.nextDouble();
            double b = scanner.nextDouble();
            goals[i] = new double[]{a, b};
        }
        for (int i = 0; i < n; i++) {
            double a = goals[i][0];
            double b = goals[i][1];
            double red = a * 100;
            double green = Math.min(10000, a * 100 * (b - 1));
            double result = 0;
            while (a > 0){
                a = (int) red / 200;
                result += (red / 10) + (green / 10);
                red =  a * 100;
                green = Math.min(10000, a * 100 * (b - 1));
            }
            System.out.println((int)result);
        }
    }

    public int countNodes(TreeNodec root) {
        if (root == null) {
            return 0;
        }
        int head = 0;
        ArrayList<TreeNodec> treeNodes = new ArrayList<>();
        treeNodes.add(root);
        while (!treeNodes.isEmpty()) {
            TreeNodec treeNodec = treeNodes.get(head++);
            if (treeNodec.left != null) treeNodes.add(treeNodec.left);
            if (treeNodec.right != null) treeNodes.add(treeNodec.right);
        }
        return treeNodes.size();
    }
}
